Component({
  properties: {
    show: {
      type: Boolean,
      value: false
    },
    title: {
      type: String,
      value: ''
    },
    duration: {
      type: Number,
      value: 1500
    }
  },
  data: {
    animationData: {}
  },
  observers: {
    'show': function(show) {
      if (show) {
        this.showToast();
      }
    }
  },
  methods: {
    showToast() {
      const animation = wx.createAnimation({
        duration: 300,
        timingFunction: 'ease',
      });
      
      // 显示动画
      animation.opacity(1).translateY(0).step();
      this.setData({
        animationData: animation.export()
      });

      // 设置定时器隐藏
      setTimeout(() => {
        animation.opacity(0).translateY(-100).step();
        this.setData({
          animationData: animation.export()
        });
        
        setTimeout(() => {
          this.setData({ show: false });
          this.triggerEvent('onHide');
        }, 300);
      }, this.data.duration);
    }
  }
});
